package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelRole;
import edu.scau.pro.hotel.mapper.HotelRoleMapper;
import edu.scau.pro.hotel.service.IHotelRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelRole)表服务实现类
 *
 * @author CJW
 * @since 2022-03-21 21:54:48
 */
@Service("hotelRoleService")
public class HotelRoleServiceImpl implements IHotelRoleService {
    @Resource
    private HotelRoleMapper hotelRoleMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param roleId 主键
     * @return 实例对象
     */
    @Override
    public HotelRole queryById(Integer roleId) {
        return this.hotelRoleMapper.queryById(roleId);
    }

    /**
     * 查询指定行
     *
     * @param hotelRole 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelRole> queryAll(HotelRole hotelRole) {
        return this.hotelRoleMapper.queryAll(hotelRole);
    }

    /**
     * 新增数据
     *
     * @param hotelRole 实例对象
     * @return 实例对象
     */
    @Override
    public HotelRole insert(HotelRole hotelRole) {
        this.hotelRoleMapper.insert(hotelRole);
        return hotelRole;
    }

    /**
     * 修改数据
     *
     * @param hotelRole 实例对象
     * @return 实例对象
     */
    @Override
    public HotelRole update(HotelRole hotelRole) {
        this.hotelRoleMapper.update(hotelRole);
        return this.queryById(hotelRole.getRoleId());
    }

    /**
     * 通过主键删除数据
     *
     * @param roleId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer roleId) {
        return this.hotelRoleMapper.deleteById(roleId) > 0;
    }
}
